Skip to content

fix(config): correct from_yaml return type and handle empty YAML files#20

Merged
sacredvoid merged 1 commit into
mainfrom
fix/from-yaml-type-and-empty
Mar 26, 2026
Merged

fix(config): correct from_yaml return type and handle empty YAML files#20
sacredvoid merged 1 commit into
mainfrom
fix/from-yaml-type-and-empty

Conversation

@sacredvoid

Copy link
Copy Markdown
Owner

Summary

  • Changes from_yaml return annotation from BaseTrainConfig to Self (fixes mypy strict + notebook IDE autocomplete)
  • Guards against yaml.safe_load() returning None for empty YAML files with (data or {}), returning all defaults instead of crashing with confusing TypeError

Fixes #19

Test plan

  • New test: test_from_yaml_empty_file for empty file
  • New test: test_from_yaml_empty_doc for YAML with only ---
  • All 151 tests pass

Two fixes:
1. Return type annotation changed from BaseTrainConfig to Self, so
   SFTConfig.from_yaml() correctly types as SFTConfig (fixes mypy
   strict and IDE autocomplete in notebooks)
2. Guard against yaml.safe_load() returning None for empty files
   with (data or {}), returning defaults instead of crashing

Fixes #19
@sacredvoid sacredvoid merged commit 34d1fd4 into main Mar 26, 2026
@sacredvoid sacredvoid deleted the fix/from-yaml-type-and-empty branch March 26, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: from_yaml return type annotation is wrong and crashes on empty YAML

1 participant